<?php
namespace Common\Model;

use Common\Model\AiModel;

class WxUserModel extends AiModel
{
    protected $tableName = 'user';

    public function wx_reg($txt){

        $res = M('User')->where("wxwebopenid=".$txt['openid']." AND unionid=".$txt['unionid'])->find();
        if($res){
            return false;
        }else{
            $data = array(
                'wxwebopenid' => $txt['openid'],
                'nickname'    => $txt['nickname'],
                'avatar'      => $txt['headimgurl'],
                'unionid'     => $txt['unionid'],
                'platformName'=> 'wxweb',
                'reg_time'    => ADD_TIME,
                'reg_ip'      => ADD_IP,
                'last_time'   => ADD_TIME,
                'last_ip'     => ADD_IP
            );
            return M('User')->add($data);
        }
    }
}